// 两数之和

let twoSum = function(nums, target) {
  let start, end, flag = false ;
  for (let i = 0; i < nums.length - 1; i++) {
    if (flag) break;
    for (let j = i + 1; j < nums.length; j++) {
      let sum = nums[i] + nums[j];
      if (sum == target) {
        start = i;
        end = j;
        flag = true;
        break;
      }
    }
  }
  return [start, end];
};

console.log(twoSum([2, 7, 11, 15, 34, 78], 9));